﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ChoDiaOc_HK_WPF.Views.QuanLy {
    /// <summary>
    /// Interaction logic for QuanLyQuyDinh.xaml
    /// </summary>
    public partial class QuanLyQuyDinh : UserControl {
        public QuanLyQuyDinh() {
            InitializeComponent();
            entities = new DBEntities();

        }
        private DBEntities entities;
        private void UserControl_Loaded(object sender, RoutedEventArgs e) {
            System.Windows.Data.CollectionViewSource myCollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["tHAMSOesViewSource"];
            myCollectionViewSource.Source = entities.THAMSOes;

        }

        private void btnNhapLai_Click(object sender, RoutedEventArgs e) {
            System.Windows.Data.CollectionViewSource myCollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["tHAMSOesViewSource"];
            entities = new DBEntities();
            myCollectionViewSource.Source = entities.THAMSOes;
        }

        private void btnHoanTat_Click(object sender, RoutedEventArgs e) {
            try {
                entities.SaveChanges();
                MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
            } catch (Exception exp) {
                MessageBox.Show(exp.Message);
            }
        }
    }
}
